<!DOCTYPE html>
<html lang="en">

<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta name="viewport"
		content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0,user-scalable=no" />
	<meta name="format-detection" content="telephone=no" />
	<meta name="format-detection" content="email=no" />
	<meta http-equiv="Pragma" content="no-cache" />
	<meta http-equiv="Cache-Control" content="no-cache" />
	<meta http-equiv="Expires" content="0" />
	<title>患者档案-糖尿病概况</title>
	<!-- 引入 vant UI 组件库样式文件 -->
	<link rel="stylesheet" href="../../common/css/vant-index.css" />
	<style rel="stylesheet">
		body {
			background-color: #f7f8fa;
		}

		a {
			-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
		}

		a:-webkit-any-link {
			color: #eee;
		}

		.container {
			border: 1px solid #f5f5f5;
			box-shadow: -1px 5px 5px #ececec;
			border-radius: 10px;
			/* margin: 0.6rem; */
			padding: 0;
		}

		.van-cell__title {
			flex: 2;
		}

		#lists {
			margin-top: 0.2rem;
			font-size: 1rem;
			font-weight: 350;
			color: #8c8b8c;
			text-align: left;
		}

		.van-cell-group--inset {
			margin: 0;
		}

		.tab-btn {
			margin: 0.2rem;
			height: 1.7rem;
			line-height: 1.7rem;
		}
	</style>
</head>

<body>
	<div id="app" v-cloak>
		<div class="container">
			<van-nav-bar title="糖尿病概况" left-text="返回" left-arrow @click-left="onClickLeft" @click-right="onClickRight">
				<template #right>
					<van-icon name="wap-home-o" size="18" />
				</template>
			</van-nav-bar>
			<van-cell-group inset>
				<van-cell>
					<template #title>
						<span class="custom-title">糖尿病诊断</span>
					</template>
					<template #value>
						{{currentData.ifDiabetes == 1 ? '未确诊' :
						currentData.ifDiabetes == 2 ? '已确诊' : '--'}}
					</template>
				</van-cell>
				<van-cell>
					<template #title>
						<span class="custom-title">糖尿病类型</span>
					</template>
					<template #value>
						{{currentData.diabetesType == 1 ? '1型糖尿病' :
						currentData.diabetesType == 2 ? '2型糖尿病' :
						currentData.diabetesType == 3 ? '妊娠糖尿病' :
						currentData.diabetesType == 4 ? '其他类型糖尿病'
						:'--'}}
					</template>
				</van-cell>
				<van-cell>
					<template #title>
						<span class="custom-title">确诊日期</span>
					</template>
					<template #value>
						{{currentData.diabetesDiagnoseDate}}
					</template>
				</van-cell>
				<van-cell>
					<template #title>
						<span class="custom-title">近半年体重是否有显著变化</span>
					</template>
					<template #value>
						{{currentData.weightState == 1 ? '无变化' :
						currentData.weightState == 2 ? '减轻' :
						currentData.weightState == 3 ? '增加' : '--'}}
					</template>
				</van-cell>
				<van-cell>
					<template #title>
						<span class="custom-title">体重变化</span>
					</template>
					<template #value>
						{{currentData.weightChange}} kg
					</template>
				</van-cell>
				<van-cell>
					<span class="custom-title">起病类型</span>
					<div id="lists" v-if="currentData.diabetesOnsetSymptom != null">
						{{currentData.diabetesOnsetSymptom.indexOf('1') !=
						-1 ? '口干 ' : ''}}
						{{currentData.diabetesOnsetSymptom.indexOf('2') !=
						-1 ? '多饮 ' : ''}}
						{{currentData.diabetesOnsetSymptom.indexOf('3') !=
						-1 ? '多尿 ' : ''}}
						{{currentData.diabetesOnsetSymptom.indexOf('4') !=
						-1 ? '多食 ' : ''}}
						{{currentData.diabetesOnsetSymptom.indexOf('5') !=
						-1 ? '消瘦 ' : ''}}
						{{currentData.diabetesOnsetSymptom.indexOf('6') !=
						-1 ? '饥饿 ' : ''}}
						{{currentData.diabetesOnsetSymptom.indexOf('7') !=
						-1 ? '手抖 ' : ''}}
						{{currentData.diabetesOnsetSymptom.indexOf('8') !=
						-1 ? '乏力 ' : ''}}
						{{currentData.diabetesOnsetSymptom.indexOf('9') !=
						-1 ? '皮肤感染 ' : ''}}
						{{currentData.diabetesOnsetSymptom.indexOf('10') !=
						-1 ? '手脚麻木 ' : ''}}
						{{currentData.diabetesOnsetSymptom.indexOf('11') !=
						-1 ? '体检发现 ' : ''}}
						{{currentData.diabetesOnsetSymptom.indexOf('12') !=
						-1 ? '视力减退 ' : ''}}
						{{currentData.diabetesOnsetSymptom.indexOf('13') !=
						-1 ? '泡沫尿 ' : ''}}
						{{currentData.diabetesOnsetSymptom.indexOf('14') !=
						-1 ? '浮肿 ' : ''}}
					</div>
				</van-cell>
				<van-cell>
					<template #title>
						<span class="custom-title">空腹血糖</span>
					</template>
					<template #value>
						{{currentData.sugarFasting}} mmol/L
					</template>
				</van-cell>

				<van-cell>
					<template #title>
						<span class="custom-title">早餐后血糖</span>
					</template>
					<template #value>
						{{currentData.sugarBreakfastAfter}} mmol/L
					</template>
				</van-cell>
				<van-cell>
					<template #title>
						<span class="custom-title">午餐前血糖</span>
					</template>
					<template #value>
						{{currentData.sugarLunchBefore}} mmol/L
					</template>
				</van-cell>
				<van-cell>
					<template #title>
						<span class="custom-title">午餐后血糖</span>
					</template>
					<template #value>
						{{currentData.sugarLunchAfter}} mmol/L
					</template>
				</van-cell>
				<van-cell>
					<template #title>
						<span class="custom-title">晚餐前血糖</span>
					</template>
					<template #value>
						{{currentData.sugarSupperBefore}} mmol/L
					</template>
				</van-cell>
				<van-cell>
					<template #title>
						<span class="custom-title">晚餐后血糖</span>
					</template>
					<template #value>
						{{currentData.sugarSupperAfter}} mmol/L
					</template>
				</van-cell>
				<van-cell>
					<template #title>
						<span class="custom-title">睡前血糖</span>
					</template>
					<template #value>
						{{currentData.sugarSleepBefore}} mmol/L
					</template>
				</van-cell>
				<van-cell>
					<template #title>
						<span class="custom-title">凌晨血糖</span>
					</template>
					<template #value>
						{{currentData.sugarSleepAfter}} mmol/L
					</template>
				</van-cell>
				<van-cell>
					<template #title>
						<span class="custom-title">糖化血红蛋白(HbA1c)</span>
					</template>
					<template #value> {{currentData.hba1c}} % </template>
				</van-cell>
				<van-cell>
					<template #title>
						<span class="custom-title">日血糖波动幅度</span>
					</template>
					<template #value>
						{{currentData.sugarWave == 1 ? '&lt;3.9mmol/L' :
						currentData.sugarWave == 2 ? '&gt;=3.9mmol/L' :
						'--'}}
					</template>
				</van-cell>
			</van-cell-group>
		</div>
	</div>
</body>
<!-- 上线环境用 -->
<script src="../../common/js/vue.global.prod.js"></script>
<!-- 引入 UI 组件库 -->
<script src="../../common/js/vant.min.js"></script>
<!-- axios 接口调用 -->
<script src="../../common/js/axios.min.js"></script>
<script src="../../base.js"></script>

<script type="module">
	import {
		getAction,
		postAction,
		getUrl,
	} from "../../common/js/api/vue3-axios-utils.js";
	const PatientData = {
		data() {
			return {
				url: {
					getInfo: "/102/10/1021002",
					updateInfo: "/102/10/1021001",
				},
				currentData: {},
				patient_url: "../index.html?userid=",
			};
		},
		created() {
			this.getData().catch((error) => {
				console.log(error);
			});
		},

		methods: {
			async getData() {
				let patientId = localStorage.pid;

				this.patient_url = this.patient_url + patientId;

				let url =
					getUrl() + this.url.getInfo + "?patientId=" + patientId;

				const res = await getAction(url);

				if (res.data.success) {
					this.currentData = await res.data.result;

					// 时间处理
					if (this.currentData.diabetesDiagnoseDate != null)
						this.currentData.diabetesDiagnoseDate =
							this.currentData.diabetesDiagnoseDate.slice(
								0,
								10
							);

					// 数据处理
					if (this.currentData.diabetesOnsetSymptom != null)
						this.currentData.diabetesOnsetSymptom =
							this.currentData.diabetesOnsetSymptom.split(
								","
							);
				}
			},
			onClickLeft() {
				window.location.href = "../filesIndex.html";
			},
			onClickRight() {
				window.location.href =
					"../index.html?userid=" + localStorage.pid;
			},
		},
	};

	const app = Vue.createApp(PatientData);

	app.use(vant);

	// 通过 CDN 引入时不会自动注册 Lazyload 组件
	// 可以通过下面的方式手动注册
	app.use(vant.Lazyload);

	// 调用函数组件，弹出一个 Toast
	// vant.Toast("刷新成功");

	app.mount("#app");
</script>

</html>
